{
    "utilScope":"function utilScope(ctx) {
    \n      return {
    }
    ;\n    }
    ","entityScope":{
    "fieldJob.form":"function view(ctx, props) {
    \n                    return {
    \n                        view: {
    \n                            type: \"FieldJobForm\",\n                            \"onFormComplete\":function(){
    \n                                ctx.helper.log(\"加载完成事件进入\")\n                                var fieldJob = props.context.getComponentByName(\"fieldJob\");\n                                var formValue = ctx.helper.getFormValue();\n                                ctx.helper.log(\"加载完成事件\",formValue)\n                                if (formValue.serviceCaseName) {
    \n                                    ctx.helper.request({
    \n                                        url: '/rest/data/v2.0/xobjects/serviceCase/' + formValue.serviceCaseName.id,\n                                        headers: {
    \n                                            'Content-Type': 'application/json'\n                                        }
    ,\n                                        method: 'GET'\n                                    }
    ).then(function (res) {
    \n                                        ctx.helper.log(\"对象查询\", res.data.data.data);\n                                        ctx.helper.setMasterFormValue({
    \n                                            fieldJobAssetId: {
    \n                                                id: res.data.data.data.customItem17__c,\n                                                name: res.data.data.data['customItem17__c-label']\n                                            }
    \n                                        }
    );\n                                    }
    ).catch(function (error) {
    \n                                        ctx.helper.error(error);\n                                    }
    );\n                                }
    \n\n                                if (formValue.zcdz__c) {
    \n                                    ctx.helper.request({
    \n                                        url: \"/rest/data/v2.0/scripts/api/crm/rwd/getAddress?address=\" + formValue.zcdz__c,\n                                        method: \"POST\"\n                                    }
    ).then(function (res) {
    \n                                        // TODO\n                                        ctx.helper.log(\"请求结果\", res);\n                                        fieldJob.context.send(\"fState\", {
    \n                                            value: res.data.data.province\n                                        }
    );\n                                        fieldJob.context.send(\"fDistrict\", {
    \n                                            value: res.data.data.district\n                                        }
    );\n                                        fieldJob.context.send(\"fCity\", {
    \n                                            value: res.data.data.city\n                                        }
    );\n                                        ctx.helper.setMasterFormValue({
    \n                                            \"address\": res.data.data.address\n                                        }
    );\n                                    }
    ).catch(function (error) {
    \n                                        ctx.helper.error(error);\n                                    }
    );\n                                }
    \n                            }
    ,\n                            controls: [{
    \n                                apiKey: \"fState\",\n                                onChange: function onChange(e) {
     }
    \n                            }
    ]\n                        }
    \n                    }
    ;\n                }
    ","lead.form":"function view(ctx) {
    \n        return {
    \n          view: {
    \n            type: \"EntityForm\",\n            controls: [{
    \n              // 具体机会点\n              apiKey: \"RWD_JTJHD__c\",\n              visibleOn: \"this.RWD_QZJHD__c == 2\",\n              required: true\n            }
    , {
    \n              // 机会潜在规模\n              apiKey: \"RWD_QZGM__c\",\n              visibleOn: \"this.RWD_QZJHD__c == 2\"\n            }
    , {
    \n              // 下一步实施计划\n              apiKey: \"RWD_XYBSSJH__c\",\n              visibleOn: \"this.RWD_QZJHD__c == 2\"\n            }
    ]\n          }
    \n        }
    ;\n      }
    ","customEntity48__c.form":"function view(ctx, props) {
    \n        ctx.helper.error(\"当前代码版本：1.3\");\n        var detailType = \"\";\n\n        var setCellValue = function setCellValue(api, rowIndex, rowData) {
    \n          ctx.helper.info(\"数据赋值\", api.getAllData()[rowIndex], rowIndex, rowData);\n\n          for (var key in rowData) {
    \n            if (rowData.hasOwnProperty(key) && key != 'temp') {
    \n              api.setCellValue(rowIndex, key, rowData[key]);\n            }
    \n          }
    \n        }
    ;\n\n        var carryAuto = function carryAuto() {
    \n          var masterFormValue = ctx.helper.getFormValue();\n          ctx.helper.info(\"carryAuto masterFormValue==\", masterFormValue); // 页面加载后触发\n\n          var masterFormInstance = props.context.getComponentByName(\"subNode\").context.getComponentByName(\"defaultBusiType_customEntity117__c_0\");\n          ctx.helper.info(\"masterFormInstance\", masterFormInstance); // 页面加载后触发\n\n          if (masterFormValue.customItem1__c && masterFormValue.customItem1__c.id && !masterFormValue.id) {
    \n            var fieldKey = \"id,name,concat(customItem58__c,'') as c58,customItem17__c,customItem17__c.name as customItem17__cname,customItem17__c.serialNumber as customItem9__c,productId.fscProductSpec as customItem8__c,productId.customItem129__c as customItem7__c,productId,productId.productName as productName\";\n            ctx.helper.request({
    \n              url: '/rest/data/v2.0/query/xoql',\n              headers: {
    \n                'Content-Type': 'application/x-www-form-urlencoded'\n              }
    ,\n              // 查明细表,     \n              data: \"xoql=select \" + fieldKey + \" from serviceCase where id = \" + masterFormValue.customItem1__c.id + \"  order by id\",\n              method: 'POST'\n            }
    ).then(function (res) {
    \n              ctx.helper.info('明细数据11--：', res.data.data.data);\n              var dataList = res.data.data.data;\n              var arrData = [];\n              dataList.records.forEach(function (k, v) {
    \n                if (k.c58 && k.c58 == 17 && !k.customItem17__c) {
    \n                  return;\n                }
    \n\n                var d = {
    }
    ;\n                d.customItem2__c = {
    \n                  id: k.id,\n                  name: k.name\n                }
    ;\n                d.customItem3__c = {
    \n                  id: k.customItem17__c,\n                  name: k.customItem17__cname\n                }
    ;\n                d.customItem7__c = k.customItem7__c;\n                d.customItem8__c = k.customItem8__c;\n                d.customItem9__c = k.customItem9__c;\n                d.customItem4__c = {
    \n                  id: k.productId,\n                  name: k.productName\n                }
    ;\n                arrData.push(d);\n              }
    );\n              masterFormInstance.api.setRowData(arrData); // 设置子表数据\n            }
    ).catch(function (error) {
    \n              ctx.helper.error(error);\n            }
    );\n          }
    \n        }
    ;\n\n        var setPriceDetailData = function setPriceDetailData(api, rowIndex, fieldApi, e) {
    \n          // 子表数据修改\n          var rowData = api.getAllData()[rowIndex];\n          rowData[fieldApi] = e;\n\n          for (var key in rowData) {
    \n            if (rowData.hasOwnProperty(key)) {
    \n              // Check if the value is undefined or null, then set it to 0\n              if (rowData[key] === undefined || rowData[key] === null || rowData[key] === \"\") {
    \n                rowData[key] = 0;\n              }
    \n            }
    \n          }
    \n\n          var setData = {
    \n            zj__c: rowData.sl__c * rowData.customItem3__c * rowData.zkl__c\n          }
    ;\n          setCellValue(api, rowIndex, setData);\n        }
    ;\n\n        return {
    \n          view: {
    \n            type: \"EntityForm\",\n            \"loadChildsData\": true,\n            controls: [{
    \n              apiKey: \"customItem27__c\",\n              visibleOn: \"this.RWD_ReceivableType__c == 4 && this.entityType == 3195400219296160\"\n            }
    , {
    \n              apiKey: \"customItem28__c\",\n              visibleOn: \"this.RWD_ReceivableType__c == 4 && this.entityType == 3195400219296160\"\n            }
    ],\n            \"onFormComplete\": function onFormComplete(completeInfo) {
    \n              ctx.helper.info(\"表单加载后==\", completeInfo); // 页面加载后触发\n\n              try {
    \n                var busiTypes = completeInfo.entityInfo.childObjects[0].busiTypes;\n\n                if (busiTypes) {
    \n                  completeInfo.entityInfo.childObjects[0].busiTypes.forEach(function (detail) {
    \n                    if (detail.mapped) {
    \n                      // Split the string based on the dots\n                      var parts = detail.labelKey.split('.'); // Reorder the parts\n\n                      detailType = parts[2] + \"_\" + parts[1] + \"_0\";\n                    }
    \n                  }
    );\n                }
     else {
    \n                  var types = completeInfo.entityInfo.childEntities[0].entityTypes[0];\n                  detailType = types.apiKey + \"_\" + types.childApiKey + \"_0\";\n                }
    \n\n                ctx.helper.info(\"明细type=\", detailType);\n              }
     catch (e) {
    }
    \n\n              ctx.helper.setTimeout(function () {
    \n                carryAuto();\n              }
    , 1500);\n            }
    ,\n            \"onSaveDetailBefore\": function onSaveDetailBefore(formValues, entityInfo) {
    \n              ctx.helper.info(\"onSaveDetailBefore=\", formValues, entityInfo);\n              var list = formValues.customEntity112__c['3104501856518434_用服报价协议明细'];\n\n              if (list.length >= 1) {
    \n                // 执行判断逻辑，是否拦截保存\n                return true;\n              }
     else {
    \n                ctx.helper.noticeError({
    \n                  message: \"请填写至少一条报价信息！\"\n                }
    );\n                return false;\n              }
    \n            }
    ,\n            subControls: [{
    \n              childApiKey: \"customEntity112__c\",\n              controls: [{
    \n                apiKey: \"cp__c\",\n                onChange: function onChange(e, props, rowIndex, api, inDialog) {
    \n                  var masterFormInstance = props.context.getComponentByName(\"subNode\").context.getComponentByName(detailType);\n                  var masterFormValue = ctx.helper.getFormValue();\n                  ctx.helper.info(\"数据赋值cp__c\", e);\n\n                  if (e && e.name && !e.name.includes(\"结算单\")) {
    \n                    masterFormInstance.api.send(rowIndex, \"wlmc__c\", {
    \n                      disabled: true\n                    }
    );\n                    masterFormInstance.api.send(rowIndex, \"ggxh__c\", {
    \n                      disabled: true\n                    }
    );\n                  }
     else {
    \n                    masterFormInstance.api.send(rowIndex, \"wlmc__c\", {
    \n                      disabled: false\n                    }
    );\n                    masterFormInstance.api.send(rowIndex, \"ggxh__c\", {
    \n                      disabled: false\n                    }
    );\n                  }
    \n                }
    \n              }
    , {
    \n                apiKey: \"sl__c\",\n                onChange: function onChange(e, props, rowIndex, api, inDialog) {
    \n                  var masterFormValue = ctx.helper.getFormValue(); //let customItem5Value = masterFormValue.customItem5__c;\n                  // ctx.helper.info(\"数据赋值\", api.getAllData()[rowIndex], rowIndex, rowData);\n\n                  setPriceDetailData(api, rowIndex, \"sl__c\", e);\n                }
    \n              }
    , {
    \n                apiKey: \"customItem3__c\",\n                onChange: function onChange(e, props, rowIndex, api, inDialog) {
    \n                  var masterFormValue = ctx.helper.getFormValue(); //let customItem5Value = masterFormValue.customItem5__c;\n                  // ctx.helper.info(\"数据赋值\", api.getAllData()[rowIndex], rowIndex, rowData);\n\n                  setPriceDetailData(api, rowIndex, \"customItem3__c\", e);\n                }
    \n              }
    , {
    \n                apiKey: \"zkl__c\",\n                onChange: function onChange(e, props, rowIndex, api, inDialog) {
    \n                  var masterFormValue = ctx.helper.getFormValue(); //let customItem5Value = masterFormValue.customItem5__c;\n                  // ctx.helper.info(\"数据赋值\", api.getAllData()[rowIndex], rowIndex, rowData);\n\n                  setPriceDetailData(api, rowIndex, \"zkl__c\", e);\n                }
    \n              }
    ]\n            }
    ],\n            \"extension\": {
    \n              \"onBatchPickerChange\": function onBatchPickerChange(data, info) {
    \n                var masterFormInstance = props.context.getComponentByName(\"subNode\").context.getComponentByName(detailType);\n                var detailList = masterFormInstance.api.getAllData();\n                var masterFormValue = ctx.helper.getFormValue();\n                ctx.helper.info(\"批量新增数据\", detailList);\n                var temp0 = detailList[0];\n\n                for (var i = 0; i < data.length; i++) {
    \n                  //总数据-本次添加的行数 得之前的数据，用之前的数据+1 得到当前行下标\n                  var currentIndex = detailList.length - data.length + i;\n                  ctx.helper.info(\"当前行\", currentIndex);\n                  var currentData = detailList[currentIndex];\n\n                  if (!currentData.cp__c.name.includes(\"结算单\")) {
    \n                    masterFormInstance.api.send(currentIndex, \"wlmc__c\", {
    \n                      disabled: true\n                    }
    );\n                    masterFormInstance.api.send(currentIndex, \"ggxh__c\", {
    \n                      disabled: true\n                    }
    );\n                  }
    \n                }
     // 接收两个参数，从info中可以获取apiKey\n                //处理明细的仓库字段\n\n\n                var apiKey = info.apiKey;\n\n                if (apiKey === \"customItem1__c\") {
    // 判断字段为当前所操作的关联字段就可以进行操作了\n                }
    \n              }
    \n            }
    \n          }
    ,\n          styles: \"\" // 全局样式扩展\n\n        }
    ;\n      }
    "}
    ,"layoutScope":{
    "quote.custom.PriceConfig":"function (ctx, props) {
    \n                    var quoteId;\n                    return {
    \n                        type: \"Custom\",\n                        //添加产品完成时\n                        addProductComplete: function (products, params) {
    \n                            debugger\n                            ctx.helper.info(\"products：\", products);\n\n                            if (products.length == 0) {
    \n                                return\n                            }
    \n                            ctx.helper.info(\"明细页面-价格表名称：\", products[0].priceListId);\n                            ctx.helper.info(\"明细页面-价格表id：\", products[0].priceListId.id);\n                            var priceId = products[0].priceListId.id;\n\n                            var fromdatea = ctx.api.getMasterData()\n                            ctx.helper.info(\"主表 表单数据：\", fromdatea);\n                            ctx.helper.info(\"主表 表单数据id：\", fromdatea.id);\n\n                            quoteId = fromdatea.id;\n                            ctx.helper.info(\"产品添加后-主表id：\", quoteId);\n\n                            ctx.helper.info(\"params\", params);\n                            //修改默认值操作\n                            if (products && products.length > 0) {
    \n                                for (let i = 0; i < products.length; i++) {
    \n                                    var pid = products[i].quotationDetailEntityRelProduct.id\n                                    ctx.helper.info(\"产品id：\", pid)\n\n                                    ctx.helper.request({
    \n                                        url: `/rest/data/v2.0/scripts/api/crm/rwd/queryPriceApi?quoteId=` + quoteId + \"&priceId=\" + priceId + \"&productId=\" + pid,\n                                        headers: {
    \n                                            'Content-Type': 'application/json'\n                                        }
    ,\n                                        data: {
    }
    ,\n                                        method: 'POST',\n                                    }
    ).then(function (res) {
    \n\n                                        var dataList = res.data.data;\n                                        ctx.helper.info('接口返回数据--：', dataList);\n                                        ctx.helper.info('接口返回数据 明细金额--：', res.data.data.price);\n                                        var price = res.data.data.price;\n                                        ctx.helper.info('明细金额--：', !(price == undefined));\n\n                                        if (!(price == undefined)) {
    \n                                            products[i].price = price;\n                                        }
    \n\n                                        // products[i].price = 88.0;\n                                        ctx.api.changeProductsDefaultValue(products, \"price\")\n                                        debugger\n\n                                    }
    ).catch(function (error) {
    \n                                        ctx.helper.error(error);\n                                    }
    );\n                                }
    \n                            }
    \n\n                            //调用方法完成默认值的修改。参数一products:修改完的产品数据。参数二：修改的字段key\n\n                            debugger\n                            ctx.helper.info(\"params\", params);\n\n                        }
    \n                    }
    \n                }
    "}
    }
    